Skip to content

Implement CloseContext remapper for PlayerQuitEvent handling#260

Merged
twisti-dev merged 2 commits intoversion/1.21.11from
fix/if-player-quit
Mar 21, 2026
Merged

Implement CloseContext remapper for PlayerQuitEvent handling#260
twisti-dev merged 2 commits intoversion/1.21.11from
fix/if-player-quit

Conversation

@twisti-dev
Copy link
Contributor

This pull request introduces a new runtime bytecode remapping solution to address a compatibility issue with the inventory-framework library, specifically around the handling of close events in inventory views. The main change is the addition of the CloseContextRemapper, which rewrites the bytecode of third-party classes so that the CloseContext class and related factory methods can accept any event object (not just InventoryCloseEvent), preventing runtime ClassCastExceptions when handling player quit events.

The most important changes are:

Bytecode Remapping for Inventory Framework Compatibility:

  • Added CloseContextRemapper in CloseContextRemapper.kt, which uses ByteBuddy and ASM to rewrite the CloseContext and BukkitElementFactory classes at runtime so that the closeOrigin parameter and field are typed as Object instead of InventoryCloseEvent. This removes unsafe casts and makes the code compatible with both InventoryCloseEvent and PlayerQuitEvent.
  • Updated InventoryLoader.kt to invoke CloseContextRemapper.remap() during initialization, ensuring the remapping is applied as soon as the inventory framework is loaded.

Versioning:

  • Bumped the project version in gradle.properties from 1.21.11-2.70.1 to 1.21.11-2.70.2 to reflect these changes.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants